package com.download.web.entity.model;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * @description:
 * @author: cmy
 * @create: 2019-02-28 18:23
 **/
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {

    private T data;
    private String msg;
    private Integer code;

    public Result(T data) {
        this.data = data;
    }

    public Result(T data, String msg) {
        this.data = data;
        this.msg = msg;
    }

    public static  <T>Result<T> ok(T t){
        return new Result<>(t,null,0);
    }

    public static  <T>Result<T> ok(T t,String msg){
        return new Result<>(t,msg,0);
    }
    public static  <T>Result<T> ok(){
        return new Result<>(null,"",0);
    }

    public static  <T>Result<T> error(String msg){
        return new Result<>(null,msg,400);
    }

}
